package com.windliven.spoc.modules.salary.salarymanagement.config;

import com.windliven.spoc.modules.salary.salarymanagement.exceptions.MyException;
import com.windliven.spoc.modules.salary.salarymanagement.pojo.vo.ResultVo;
import com.windliven.spoc.modules.salary.salarymanagement.utils.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author fly
 * @version V1.0
 * @date 2018/11/14
 */
@ControllerAdvice
public class ExceptionHandle {

    @ResponseBody
    @ExceptionHandler(value = MyException.class)
    public ResultVo myExceptionHandler(MyException ex) {
        return ResultUtil.error(ex.getResultEnum());
    }
}
